<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <input type="button" value="添加数据" @click="add( { name: 'red'})">
        <input type="button" value="删除数据" @click="remove">
        <ul>
            <li v-for="(item,index) in arr " :title='item'>
                {{ item }} {{ index+1 }}
            </li>
        </ul>
        <h2 v-for="(item,index) in objArr">
            {{ item.name }}
        </h2>
    </div>
    <script>
        var app = new Vue({
            el: "#app",
            data: {
                arr: [1, 2, 3, 4, 5],
                objArr: [
                    { name: "jack" },
                    { name: "rose" }
                ]
            },
            methods: {
                add: function (p) {
                    this.objArr.push(p);
                },
                remove: function () {
                    this.objArr.shift();
                }
            }
        })
    </script>
</body>

</html>